<template>
  <!-- 新增录入画面对话框-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
 >
    <el-form ref="editForm" :model="form" :rules="rules" label-width="110px">
      <!--交易础信息-->
      <el-card class="form-card txnInfo-card">
        <div slot="header" class="label-header-msg">
          <span>交易基础信息</span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="业务类型" prop="bizTypeCode">
              <el-select v-model="form.bizTypeCode" placeholder="业务类型" disabled>
                <el-option
                  v-for="dict in dictMap.BIZ_TYPE_111"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
               ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务种类" prop="bizCtgyCode">
              <el-select v-model="form.bizCtgyCode" placeholder="业务种类" disabled>
                <el-option
                  v-for="dict in  dictMap.BIZ_CTGY"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
               ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务优先级" prop="bizPriority">
              <el-select v-model="form.bizPriority" placeholder="业务优先级" disabled>
                <el-option
                  v-for="dict in dictMap.PRIORITY3CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
               ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>


        <el-row>
          <el-col :span="8">
            <el-form-item label="交易币种" prop="curcd">
              <el-input v-model="form.curcd" placeholder="人民币-CNY" :disabled="true"/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="行内系统序号" prop="custId">
              <el-input v-model="form.custId" placeholder="行内系统序号" :disabled="true"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--付款人信息-->
      <el-card class="form-card payerInfo-card">
        <div slot="header" class="label-header-msg">
          <span>付款人信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="付款人账号" prop="payerActno">
              <el-input
                v-model="form.payerActno"
                placeholder="付款人账号"
                disabled
              />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人名称" prop="payerName">
              <el-input v-model="form.payerName" placeholder="付款人名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="付款人地址" prop="payerAddr">
            <el-input v-model="form.payerAddr" placeholder="付款人地址" disabled/>
          </el-form-item>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="grid-payer">
              <el-form-item label="付款行行号" prop="payerBrno">
                <el-input
                  disabled
                  v-model="form.payerBrno"
                  placeholder="付款行行号"
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款行行名" prop="payerBrName" label-width="130px">
              <el-input v-model="form.payerBrName" disabled placeholder="付款行行名"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="grid-payer">
              <el-form-item label="付款人开户行号" prop="payerAccBrno">
                <el-input
                  v-model="form.payerAccBrno"
                  placeholder="付款人开户行行号"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款人开户行行名" prop="payerAccBrname" label-width="130px">
              <el-input v-model="form.payerAccBrname" disabled placeholder="付款人开户行行名"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--收款人信息-->
      <el-card class="form-card payeeInfo-card">
        <div slot="header" class="label-header-msg">
          <span>收款人信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款人账号" prop="payeeActno">
                <el-input
                  v-model="form.payeeActno"
                  placeholder="收款人账号"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人名称" prop="payeeName">
              <el-input v-model="form.payeeName" placeholder="收款人名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="收款人地址" prop="payeeAddr">
              <el-input v-model="form.payeeAddr" placeholder="收款人地址" disabled/>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款行行号" prop="payeeBrno">
                <el-input
                  v-model="form.payeeBrno"
                  placeholder="收款行行号"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行名" prop="payeeBrName" label-width="130px">
              <el-input v-model="form.payeeBrName" placeholder="收款行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="grid-payee">
              <el-form-item label="收款人开户行号" prop="payeeAccBrno">
                <el-input
                  v-model="form.payeeAccBrno"
                  placeholder="收款人开户行行号"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款人开户行行名" prop="payeeAccBrname" label-width="130px">
              <el-input v-model="form.payeeAccBrname" placeholder="收款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--其他信息-->
      <el-card class="form-card payOtherInfo-card">
        <div slot="header" class="label-header-msg">
          <span>其他交易信息</span>
        </div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="交易金额" prop="amount">
              <ht-amount-input
                v-model="form.amount"
                placeholder="交易金额"
                :disable="true"
             ></ht-amount-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="大写金额" prop="bAmount">
              <div class="upper-amount-container">
                <ht-amount-upper :inputValue="form.amount" placeholder="交易金额"
                                 style="width: 195px"></ht-amount-upper>
              </div>
            </el-form-item>

          </el-col>
        </el-row>

        <el-row>
          <el-col :span="12">
            <div class="grid-otherInfo">
              <el-form-item label="中介机构1" prop="agency1">
                <el-input
                  v-model="form.agency1"
                  placeholder="中介机构1"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中介机构1名称" prop="agency1name" label-width="130px">
              <el-input v-model="form.agency1name" placeholder="中介机构1名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <div class="grid-otherInfo">
              <el-form-item label="中介机构2" prop="agency2">
                <el-input
                  v-model="form.agency2"
                  placeholder="中介机构2"
                  disabled
                />
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="12">
            <el-form-item label="中介机构2名称" prop="agency2name" label-width="130px">
              <el-input v-model="form.agency2name" placeholder="中介机构2名称" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="备注" prop="remarks">
                <el-input type="textarea" v-model="form.remarks" placeholder="备注" disabled/>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="附言" prop="memo">
                <el-input type="textarea" v-model="form.memo" placeholder="附言" disabled/>
              </el-form-item>
            </div>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <div class="grid-otherInfo">
              <el-form-item label="拒绝描述" prop="procInfo">
                <el-input type="textarea" v-model="form.procInfo" placeholder="拒绝描述"/>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
      </el-card>


    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve()" v-loading.fullscreen.lock="loading">审 核</el-button>
      <el-button type="primary" @click="reject()" v-loading.fullscreen.lock="loading">拒 绝</el-button>
      <el-button @click="cancel">关 闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import HtAmountInput from "@/views/components/HtAmountInput";
import HtAmountUpper from "@/views/components/HtAmountUpper";
import { approve, approveDetail, reject } from "@/api/cnaps/bizMng/batchFileUpload";

export default {
  name: "EditInfo",
  components: {
    HtAmountInput,
    HtAmountUpper,
  },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      busTypeList: [],
      id: "",
      title: "",
      pkgNo: "",
      // 是否显示弹出层
      openState: false,
      ifShowDelBtn: false,
      isEdit: false,

      loading: false,

      // 字段可编辑控制

      // 表单参数
      form: {
        amount: 0.00,
        curcd: "CNY",
      },
      // 表单校验
      rules: {

      },
    };
  },
  mounted() {
  },
  computed: {
  },
  methods: {
    // 表单重置
    reset() {
      this.resetForm("editForm");
      this.$set(this, "form", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {
        });
    },

    show(id = "") {
      this.reset();
      this.id = id;
      this.title = "批量文件审核";
      this.openState = true;
      this.ifShowDelBtn = false;
      approveDetail({
          id: this.id,
        }).then((res) => {
          console.log(res.result.data)
          this.$set(this, "form", res.result.data);
        });
      },
    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", false);
    },
    /** TODO提交按钮 */
    approve: function () {
      this.$refs["editForm"].validate((valid) => {
        if (valid) {
          this.loading = true;
          approve(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审核成功");
              this.loading = false;
              this.$emit("editComplete", true);
              this.openState = false;
            }
          }) .catch((err) => {
            this.loading = false;
          });
        }
      });
    },

    reject: function () {
      this.$refs["editForm"].validate((valid) => {
        if (valid) {
          this.loading = true
          reject(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("拒绝成功");
              this.loading = false;
              this.$emit("editComplete", true);
              this.openState = false;
            }
          }) .catch((err) => {
            this.loading = false;
          });
        }
      });
    },

  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
